# coding=utf-8
# !/usr/bin/python3
import json

import execjs
import requests

cookies = {
    'Hm_lvt_6146f11e5afab71309b3accbfc4a932e': '1725539915',
    'HMACCOUNT': 'ED0735D1CE0FB96D',
    'JSESSIONID': 'E0CCDFE0ABCC01DC57D1ED04247D7FDC',
    'Hm_lpvt_6146f11e5afab71309b3accbfc4a932e': '1725540175',
}

headers = {
    'Accept': 'application/json, text/plain, */*',
    'Accept-Language': 'zh-CN,zh;q=0.9',
    'Cache-Control': 'no-cache',
    'Connection': 'keep-alive',
    'Content-Type': 'application/octet-stream',
    # 'Cookie': 'Hm_lvt_6146f11e5afab71309b3accbfc4a932e=1725539915; HMACCOUNT=ED0735D1CE0FB96D; JSESSIONID=E0CCDFE0ABCC01DC57D1ED04247D7FDC; Hm_lpvt_6146f11e5afab71309b3accbfc4a932e=1725540175',
    'Origin': 'https://www.spolicy.com',
    'Pragma': 'no-cache',
    'Referer': 'https://www.spolicy.com/',
    'Sec-Fetch-Dest': 'empty',
    'Sec-Fetch-Mode': 'cors',
    'Sec-Fetch-Site': 'same-origin',
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36',
    'sec-ch-ua': '"Chromium";v="128", "Not;A=Brand";v="24", "Google Chrome";v="128"',
    'sec-ch-ua-mobile': '?0',
    'sec-ch-ua-platform': '"Windows"',
}
datas={
    "policyType": "6",
    "province": "",
    "city": "",
    "downtown": "",
    "garden": "",
    "centralId": "",
    "sort": 0,
    "homePageFlag": 1,
    "pageNum": 1,
    "pageSize": 7
}
with open('loader.js', 'r', encoding='utf-8') as js_file:
    js_code = js_file.read()
js_compile = execjs.compile(js_code).call('okk',datas)['data']




response = requests.post('https://www.spolicy.com/info_api/policyType/showPolicyType', cookies=cookies, headers=headers, data=bytes(js_compile)).json()
print(json.dumps(response, ensure_ascii=False, indent=4))